<?php
	@session_start();
	require_once('../../lib/'.'BaseDir.inc.htm');
	require_once (EIU_LIB.'View.class.htm');
	require_once('../../lib/'.'DBCommon.class.htm');
	require_once (EIU_CLASS.'LoginClass.htm');
	require_once (EIU_CLASS.'BaseClass.htm');

	
	$view = new View();
	$data="";
	
	$oDB = new DBCommon();
	$conn =  $oDB->stl_openConn();
	

	if(isset($_GET['record']) && !empty($_GET['record']))
	{
		$data = selectALlTable('*', '`invoice_tbl`', "`isDeleted`=0 AND `InvcNo`='".$_GET['record']."'");
		$data1 = get_object_vars($data[0]);
		
		if(!empty($data1['InvcNo']))
		{
			$q_select="SELECT * FROM `image_tbl` WHERE `isDeleted`=0 and `InvcNo`='".$data1['InvcNo']."'";
			$rs=$oDB->stl_db_select($q_select, $conn);
			//print_r($rs);
			$i = 0;
			if(is_array($rs))
			{
				foreach($rs as $key=>$value)
				{
					$dat['ImageID'] =$rs[$key]->ImageID;
					$dat['Name'] = $rs[$key]->Url;
					$dat['Url'] = EIU_IMAGE_STAFF.$rs[$key]->Url;
					$arr["Result"][$i] = $dat;
					$i++;
				}
				$data1['image']=json_encode($arr);
				//$data1['image'] = EIU_IMAGE_STAFF.$data1['InvcImage'];
				$data1['InvcDate'] = changeDateFormat($data1['InvcDate'],"");
				
			}
			
			if(isset($_SESSION['userID'])&&!empty($_SESSION['userID']))
			{
				//Set init value info
				$data["titlePage"] = "A1.1. CHI TIẾT HỢP ĐỒNG/HÓA ĐƠN";	
				$data1["titlePage"] = $data["titlePage"];	
				
				
				$data['userName'] 			= $_SESSION['userName'];
				$data['userLoginTime'] 		= $_SESSION['userLoginTime'];
				$data['userId'] 			= $_SESSION['userID'];
				$data['userEID']			= $_SESSION['userEID'];
				$data['isLogin']			= $_SESSION['isLogin'];		
				
				
				$data1["Header"] = $view->returnTmpl("header.tmpl","n",$data);
				
				$view->showTmpl("invoiceDetail.tmpl","n",$data1);
			}
			else
			{
				$strLocation = "login.htm";
				echo '<script type="text/javascript">';
				echo " location.href='".$strLocation."';";
				echo "</script>";
			}	
			
		
			//$data1['userId']=$_SESSION['userID'];
			//print_r($data1);
			
		}
	}
	else
	{
		$data="";
		$view->showTmpl("invcInsert.tmpl","n",$data);
		echo '<script type="text/javascript">';
		echo "var record = ''";
		echo '</script>';
	}
?>
